<template>
	<view class="content">
		<view class="header">
			<view class="view" v-for="(item,index) in columns" :key="index" @click="getindex(index)">
				<text :style="{'border-bottom':index == inx ? '3px solid #029CFE' : '3px solid #fde8d0',
				'color':index == inx ? '#029CFE' : '#4C4C4C'}">{{item.label}}</text>
			</view>
		</view>
		<view class="Box">
			<view v-for="(item,index) in lists" :key="index" class="BoxView" @click="xuanka(item.id)">
				<view class="BoxOne">
					<u--image :showLoading="true" :src="item.course_image" width="84rpx" height="82rpx"
						radius="0"></u--image>
					<view class="BoxTop">
						<text class="title">{{item.name || ''}}</text>
						<text style="color:#888888;">卡号：{{item.cart || ''}}</text>
					</view>	
				</view>
				<view class="BoxTime">
					<view>
						<u--image :showLoading="true" src="../../static/logo.png" width="26rpx" height="26rpx"
							radius="0"></u--image>
						<text>{{item.start_time || ''}}至{{item.end_time || ''}}</text>
					</view>
						<view>
							<u--image :showLoading="true" src="../../static/logo.png" width="24rpx" height="24rpx"
								radius="0"></u--image>
							<text>{{item.usage || ''}}次/{{item.total || ''}}次</text>
						</view>
				</view>
				<u-line-progress :percentage="(item.usage/item.total)*100" height="15"></u-line-progress>
			</view>
		</view>
		<view class="null" v-if="lists.length == 0">
			<u--image :showLoading="true" src="../../static/null.png" width="328rpx" height="328rpx"
				radius="0"></u--image>
		</view>
	</view>
</template>

<script>
import {
		getUserVip
	 } from '../../api/Mine.js';
	export default {
		data() {
			return {
				show: false,
				inx:0,
				columns: [{
					label: '有效卡',
					// 其他属性值
					id: 1
					// ...
				}, {
					label: '失效卡',
					id: 2
				}],
				req:{
					shop_id:1,
					type:1,//1有效卡，2无效卡
				},
				lists:[]
			}
		},
		onLoad(){
			this.getUserVip();
		},
		methods: {
			xuanka(e){
				console.log(e,'hhhhh')
				uni.navigateBack()
				uni.$emit('changeInvoiceClose',{id:e})
			},
			getindex(index){
				this.inx = index
				this.req.type = this.columns[index].id
				console.log(this.columns[index])
				this.getUserVip();
			},
			/**
			@method 老师列表
			**/
			async getUserVip() {
				try {
					let type = this.req.type;
					const res = await getUserVip({
						shop_id: uni.getStorageSync('shop_id') ?? 1,
						type:type,
						page: 1,
						limit: 999
					});
					this.lists = [...res.data];
				} catch (err) {
					//TODO handle the exception
					console.log(err);
				}
			},
		}
	}
</script>

<style>
	page{
		background-color:#f6f7f9;
	}
</style>
<style scoped lang="scss">
	.content {
		.null{
			width:100%;
			display: flex;
			justify-content: center;
			padding-top:50rpx;
		}
		.header {
			width: auto;
			background-color: #fde8d0;
			padding: 30rpx 30rpx 0rpx 30rpx;
			display: flex;
			align-items: center;

			.view {
				width: auto;
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-right:160rpx;
				
				text {
					border-bottom:3px solid transparent;
					padding-bottom:20rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 600;
					font-size: 28rpx;
				}
			}
		}

		.Box{
			.BoxView{
				width:85%;
				margin:0px auto;
				background-color: #fff;
				border-radius:20rpx;
				padding:30rpx 40rpx 30rpx 40rpx;
				margin-top:20rpx;
			}
			.BoxOne{
				display: flex;
				align-items: center;
				.BoxTop{
					margin-left:20rpx;
					text{
						display: block;
						font-size:24rpx;
						margin-bottom:5rpx;
					}
					.title{
						font-family: PingFangSC, PingFang SC;
						font-weight: 600;
						font-size: 32rpx;
						color: #333333;
						font-style: normal;
					}
				}
			}
		}
		.BoxTime{
			display: flex;
			align-items: center;
			margin-top:20rpx;
			margin-bottom:20rpx;
			view{
				display: flex;
				align-items: center;
				text{
					margin-left:10rpx;
					margin-right:30rpx;
				}
			}
		}
	}
</style>